package me.zhanshi123.invitelink;

import me.zhanshi123.invitelink.metrics.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class Main extends JavaPlugin {
    private static Main instance;
    private static ConfigManager configManager;
    private static Database database;

    public static ConfigManager getConfigManager() {
        return configManager;
    }

    public static Main getInstance() {
        return instance;
    }

    public static Database getPluginDatabase() {
        return database;
    }

    @Override
    public void onEnable() {
        instance = this;
        configManager = new ConfigManager();
        database = new Database();
        Metrics metrics = new Metrics(instance);
        new UpdateCheckTask().runTaskAsynchronously(instance);
        new AdBroadcastTask().runTaskAsynchronously(instance);
        Bukkit.getPluginCommand("invite").setExecutor(new Commands());
    }

    @Override
    public void onDisable() {
        database.release();
    }
}
